package module.building.view.buildingUpPanel
{
	import com.darwin.darwinUI.controls.Tab;
	import com.darwin.darwinUI.core.UIComponent;
	
	import flash.display.Sprite;
	
	import module.building.model.dataObj.BuildingObj;
	import module.main.view.ResourceConst;

	public class UpgradeTab extends Tab
	{
		private var _image:Sprite;
		private var _level:int;
		
		private var icon:UIComponent;
		private var selectedTab:UIComponent;
		private var arrow:UIComponent;
		
		public function UpgradeTab(image:Sprite,level:int)
		{
			super();
			_image = image;
			_level = level;		
			mouseChildren =
				mouseEnabled  = false;
			init();
		}
		
		private function init():void
		{
			selectedTab = new UIComponent();
			selectedTab.backgroundSkin = ResourceConst.BUILD_TAB_SELECTED_BG;
			selectedTab.backgroundAuto = true;
			addChild(selectedTab);
			
			_image.x = 7;
			_image.y = 8;			
			addChild(_image);
			
			var romeNumber:UIComponent = new UIComponent();
			romeNumber.backgroundSkin = ResourceConst.ROME_ICON + "_" + (_level+1);
			romeNumber.backgroundAuto = true;
			romeNumber.x = 35;
			romeNumber.y = 30;
			addChild(romeNumber);
			
			arrow = new UIComponent();
			arrow.backgroundSkin = ResourceConst.UPGRADE_ARROW;
			arrow.backgroundAuto = true;
			arrow.x = 56;
			arrow.y = 20;
//			addChild(arrow);
		}
		
		override public function selectAction(select:Boolean):void
		{
			super.selectAction(select);
			if(select){
				selectedTab.visible = true;
				arrow.visible = true;
			}else{
				selectedTab.visible = false;
				arrow.visible = false;
			}
		}
	}
}